
LOADADDR = 0xa0040000
RAMSIZE = 0x00100000		# 1MB

CROSS_COMPILE = arm-none-eabi-

######## END OF CONFIGURATION #########

.S.s:
	$(CPP) $(CFLAGS) $< -o $*.s
.S.o:
	$(CC) $(CFLAGS) -c $< -o $*.o
.c.o:
	$(CC) $(CFLAGS) -c $< -o $*.o

CC =       $(CROSS_COMPILE)gcc
LD =       $(CROSS_COMPILE)gcc
OBJCOPY =  $(CROSS_COMPILE)objcopy
OBJDUMP =  $(CROSS_COMPILE)objdump

# debug:
#CFLAGS = -O0 -g -Wall -I. -I./tstv -march=armv6k -mtune=arm1176jz-s  -msoft-float
# profile:
CFLAGS = -O2 -g -Wall -I. -I./tstv -march=armv6k -mtune=arm1176jz-s  -msoft-float

CFLAGS0 = -O0 -g -Wall -I. -I./tstv -march=armv6k -mtune=arm1176jz-s  -msoft-float


# Drop some uninteresting sections in the kernel.
# This is only relevant for ELF kernels but doesn't hurt a.out
drop-sections   = .reginfo .mdebug
strip-flags     = $(addprefix --remove-section=,$(drop-sections))


all : elf srec bin

srec : barebone.srec
elf : barebone.elf
bin : barebone.bin

barebone.elf :	agc.o \
c4_17pf.o \
count.o \
d_gain_c.o \
ex_ctrl.o \
lag_wind.o \
ol_ltp.o \
prm2bits.o \
r_fft.o \
TestProf_AMR_NB.o \
a_refl.o \
c8_31pf.o \
d1035pf.o \
d_gain_p.o \
g_adapt.o \
levinson.o \
oper_32b.o \
pstfilt.o \
s10_8pf.o \
ton_stab.o \
autocorr.o \
calc_cor.o \
d2_11pf.o \
d_homing.o \
gain_q.o \
lflg_upd.o \
ph_disp.o \
qgain475.o \
set_sign.o \
vad1.o \
az_lsp.o \
calc_en.o \
d2_9pf.o \
d_plsf_3.o \
g_code.o \
log2.o \
pitch_fr.o \
qgain795.o \
set_zero.o \
vad2.o \
basicop2.o \
cbsearch.o \
d3_14pf.o \
d_plsf_5.o \
gc_pred.o \
lpc.o \
pitch_ol.o \
q_gain_c.o \
sid_sync.o \
vadname.o \
b_cn_cod.o \
c_g_aver.o \
d4_17pf.o \
d_plsf.o \
gmed_n.o \
p_ol_wgh.o \
q_gain_p.o \
sp_dec.o \
weight_a.o \
bgnscd.o \
cl_ltp.o \
d8_31pf.o \
dtx_dec.o \
g_pitch.o \
lsp_avg.o \
post_pro.o \
q_plsf_3.o \
sp_enc.o \
bits2prm.o \
cod_amr.o \
dec_amr.o \
dtx_enc.o \
hp_max.o \
lsp_az.o \
pow2.o \
q_plsf_5.o \
spreproc.o \
c1035pf.o \
dec_gain.o \
ec_gains.o \
inter_36.o \
lsp.o \
pre_big.o \
q_plsf.o \
spstproc.o \
c2_11pf.o \
convolve.o \
dec_lag3.o \
e_homing.o \
int_lpc.o \
lsp_lsf.o \
pred_lt.o \
qua_gain.o \
sqrt_l.o \
c2_9pf.o \
copy.o \
dec_lag6.o \
enc_lag3.o \
int_lsf.o \
mac_32.o \
preemph.o \
reorder.o \
c3_14pf.o \
cor_h.o \
enc_lag6.o \
inv_sqrt.o \
pre_proc.o \
residu.o \
syn_filt.o \
lsfwt.o \
counter.o \
basicops.o \
calc_cor_asm.o \
syn_filt_asm.o \
convolve_asm.o \
myp_32_16_asm.o \
residu_asm.o \
L_extract_asm.o \

	
	$(LD)  -Lgcc -lm -e main -L. -nostartfiles -o barebone.elf -N -Tbarebone.lds -Ttext $(LOADADDR) $^


barebone.srec : barebone.elf
	$(OBJCOPY) -S -O srec $(strip-flags) barebone.elf barebone.srec

barebone.bin : barebone.elf
	$(OBJCOPY) -S -O binary $(strip-flags) barebone.elf barebone.bin

TestProf_AMR_NB.o: TestProf_AMR_NB.c
	$(CC) $(CFLAGS0) -c  $< -o $*.o

clean:
	del *.o barebone.elf barebone.srec barebone.bin

